<?php
namespace app\shop\library\order\item;

use app\shop\library\order\OrderItem;
use app\shop\library\order\Order;
use cubox\Cubox;

class freight extends OrderItem{

    public function count(Order &$order){
        $app = Cubox::app('shop');
        $freight = $app->config('freight');
        $free = $freight->free??0;
        $freightMoney  = $freight->money??0;
        if ($order->total() < $free && $freightMoney >0 ){
            $desc = $freight->desc!=''?$freight->desc:'满'.$free.'免运费';
            $order->addDetail('freight',$freightMoney, $desc);
        }else{
            $order->addDetail('freight',0,$freight->desc);
        }
    }

    public function save(Order $order){

    }
}